using System.Collections;
using System.Windows;
using System.Windows.Controls;

namespace Select.Control.FormItem;

public partial class SelectFormItem : UserControl
{
    public string Label { get; set; }

    public static readonly DependencyProperty OptionsProperty =
        DependencyProperty.Register("Options", typeof(IEnumerable), typeof(SelectFormItem), new PropertyMetadata(null));

    public IEnumerable Options
    {
        get => (IEnumerable)GetValue(OptionsProperty);
        set => SetValue(OptionsProperty, value);
    }

    public static readonly DependencyProperty SelectedItemProperty =
        DependencyProperty.Register("SelectedItem", typeof(object), typeof(SelectFormItem),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));

    public object SelectedItem
    {
        get => GetValue(SelectedItemProperty);
        set => SetValue(SelectedItemProperty, value);
    }

    public SelectFormItem()
    {
        InitializeComponent();
        this.DataContext = this; // 或根据需要设置为合适的上下文
    }
}